﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ApprovalFlow.Interface;

namespace ApprovalFlow.Models
{
    internal class ApprovalExecutor : IApprovalExecutor
    {
        private readonly IWorkflowHost _workflowHost;

        public ApprovalExecutor(IWorkflowHost workflowHost)
        {
            this._workflowHost = workflowHost;
        }

        /// <summary>
        /// 同意审批
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="eventKey"></param>
        /// <param name="remark"></param>
        /// <returns></returns>
        async Task IApprovalExecutor.Agree(string eventKey, string remark)
        {
            var eventData = new ApprovalActionOptions() { Result = "agree", Remark = remark };
            await this._workflowHost.PublishEvent(eventKey, eventData);
        }


        async Task IApprovalExecutor.Refuse(string eventKey, string remark)
        {
            var eventData = new ApprovalActionOptions() { Result = "refuse", Remark = remark };
            await this._workflowHost.PublishEvent(eventKey, eventData);
        }

        async Task IApprovalExecutor.TerminateWorkflow(string instance_id)
        {
            await _workflowHost.TerminateWorkflow(instance_id);
        }

        Task IApprovalExecutor.AppendTaskAfter(string eventName, string eventKey, string[] user_id, string remark)
        {
            throw new NotImplementedException();
        }

        Task IApprovalExecutor.AppendTaskBefore(string eventName, string eventKey, string[] user_id, string remark)
        {
            throw new NotImplementedException();
        }

        Task IApprovalExecutor.RedirectProcess(string eventName, string eventKey, string nodeName, string remark)
        {
            throw new NotImplementedException();
        }

        Task IApprovalExecutor.RedirectTask(string eventName, string eventKey, string user_id, string remark)
        {
            throw new NotImplementedException();
        }
    }
}
